import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
import numpy as np
data = pd.read_csv('E:\Project 3\Energy-saving House.csv')
data
time_index = pd.date_range('2016-01-01 00:00:00', periods=len(data), freq='min')
time_index = pd.DatetimeIndex(time_index)
data = data.set_index(time_index)
data['time']=time_index
data
From the above, the time recorded in the dataset is from 2016-01-01 00:00:00 to 2016-12-15 22:29:00.
data = data[0:-1]
data.shape
data['use [kW]'].head()
data['House overall [kW]'].head()
(data['use [kW]']-data['House overall [kW]']).value_counts()
fig, axes = plt.subplots(nrows=2, ncols=1)
data['use [kW]'].plot(ax=axes[0],figsize=(20,7))
data['House overall [kW]'].plot(ax=axes[1],figsize=(20,7))
data = data.drop(columns = 'use [kW]')
data
data['gen [kW]'].head()
data['Solar [kW]'].head()
(data['gen [kW]']-data['Solar [kW]']).value_counts()
fig, axes = plt.subplots(nrows=2, ncols=1)
data['gen [kW]'].plot(ax=axes[0],figsize=(20,7))
data['Solar [kW]'].plot(ax=axes[1],figsize=(20,7))
data = data.drop(columns = ['gen [kW]'])
data
house_overall_data = data.filter(items=['House overall [kW]'])
house_data = data.filter(items=['Dishwasher [kW]', 'Furnace 1 [kW]',
'Furnace 2 [kW]', 'Home office [kW]',
'Fridge [kW]', 'Wine cellar [kW]',
'Garage door [kW]', 'Kitchen 12 [kW]',
'Kitchen 14 [kW]', 'Kitchen 38 [kW]',
'Barn [kW]', 'Well [kW]',
'Microwave [kW]', 'Living room [kW]'])
solar_data = data.filter(items=['Solar [kW]'])
house_overall_data.head()
house_data.head()
solar_data.head()
# Set the width and height of the figure
plt.figure(figsize=(20,7))
# Add title
plt.title("House Overall Energy Consumption on October 7, 2016")
sns.lineplot(data = house_overall_data.loc['2016-10-07 00:00':'2016-10-07 23:59'].resample(
'H').sum(), dashes=False)
From the above plot: the highest overall house energy consumption is at 6:00 on October 7, 2016; the lowest overall house energy consumption is at 13:00 on October 7, 2016.
plt.figure(figsize=(20,7))
plt.title("Overall House Energy Consumption per Month")
sns.lineplot(data = house_overall_data.resample('M').sum(), dashes=False)
From the above plot: the highest energy consumption is in August and September; the lowest energy consumption is in July and December.
plt.figure(figsize=(20,7))
plt.title("Specific House Energy Consumption on October 7, 2016")
sns.lineplot(data = house_data.loc['2016-10-07 00:00':'2016-10-07 23:59'].resample(
'H').sum(), dashes=False)
From the above plot: higher house energy consumption shows from 6:00 to 12:00. During this period time, living room and barn has higher energy consumption and is quite lively.
plt.figure(figsize=(20,7))
plt.title("Specific House Energy Consumption per Month")
sns.lineplot(data = house_data.resample('M').sum(), dashes=False)
From the above plot: furnace 2 and 1 has the higher energy consumption in the house before May 2016.
plt.figure(figsize=(20,7))
plt.title("Solar Power Generation on October 7, 2016")
sns.lineplot(data = solar_data.loc['2016-10-07 00:00':'2016-10-07 23:59'].resample('H').sum(),
dashes=False)
From above plot: solar generates the stronger power between 11:00 and 13:00 on October 7, 2016.
plt.figure(figsize=(20,7))
plt.title("Solar Power Generation per Month")
sns.lineplot(data = solar_data.resample('M').sum(), dashes=False)
From above plot: solar generates the strongest power in July; solar generates the weakest power in December and January.
plt.figure(figsize=(20,7))
plt.title("Overall House Energy Consumption and Solar Power Generation at October 7, 2016")
sns.lineplot(data = data.loc['2016-10-07 00:00':'2016-10-07 23:59'].filter(items=['House overall [kW]', 'Solar [kW]']
).resample('H').sum(), dashes=False)
From the above plot, the balance between overall house energy consumption and solar power generation is 9:00 and 13:30.
plt.figure(figsize=(20,7))
plt.title("Overall House Energy Consumption and Solar Power Generation per Month")
sns.lineplot(data = data.filter(items=['House overall [kW]', 'Solar [kW]']).resample('M').sum(), dashes=False)
From the above plot, overall house energy consumption is greater than solar power generation in 2016.
room_data = house_data.filter(items=['Home office [kW]', 'Wine cellar [kW]',
'Kitchen 12 [kW]', 'Kitchen 14 [kW]',
'Kitchen 38 [kW]', 'Barn [kW]',
'Living room [kW]'])
device_data = house_data.filter(items=['Dishwasher [kW]', 'Furnace 1 [kW]',
'Furnace 2 [kW]', 'Fridge [kW]',
'Garage door [kW]', 'Well [kW]',
'Microwave [kW]'])
room_data = room_data.sum()
device_data = device_data.sum()
print(room_data)
print(device_data)
plt.figure(figsize=(20,7))
plt.title("Rooms Energy Consumption")
sns.lineplot(data = room_data, dashes=False)
plot = room_data.plot(kind="bar", figsize=(20,7))
plot.set_title("Rooms Energy Consumption")
plot.set_ylabel('%')
import plotly.graph_objects as go
fig = go.Figure(
data=[go.Bar(y=room_data, x=['Home office [kW]', 'Wine cellar [kW]',
'Kitchen 12 [kW]', 'Kitchen 14 [kW]',
'Kitchen 38 [kW]', 'Barn [kW]',
'Living room [kW]'])],
layout_title_text="Room Energy Consumption"
)
fig.show()
From above plots: home office has the highest consumption, which is 40.96128 kW; kitchen 38 has lowest energy consumption, which is 0 kW.
plot = room_data.plot(kind="pie", autopct='%.2f', figsize=(7,7))
plot.set_title("Rooms Energy Consumption")
plot.set_ylabel('%')
plt.figure(figsize=(20,7))
plt.title("Devices Energy Consumption")
sns.lineplot(data = device_data, dashes=False)
plot = device_data.plot(kind="bar", figsize=(20,7))
plot.set_title("Devices Energy Consumption")
plot.set_ylabel('%')
import plotly.graph_objects as go
fig = go.Figure(
data=[go.Bar(y=device_data, x=['Dishwasher [kW]', 'Furnace 1 [kW]',
'Furnace 2 [kW]', 'Fridge [kW]',
'Garage door [kW]', 'Well [kW]',
'Microwave [kW]'])],
layout_title_text="Devices Energy Consumption"
)
fig.show()
From above plots, Furnace 2 has the highest energy consumption, which is 68.9244 kW; Microwave has the lowest energy consumption, which is 5.53444 W.
plot = device_data.plot(kind="pie", autopct='%.2f', figsize=(7,7))
plot.set_title("Devices Energy Consumption")
plot.set_ylabel('%')
Conclusion:
On October 7, 2016, the highest overall house energy consumption was at 6:00; the lowest overall house energy consumption was at 13:00. The higher house energy consumption was from 6:00 to 12:00. During this period time, living room and barn had higher energy consumption and was quite lively. Solar generated the stronger power between 11:00 and 13:00. The balance between overall house energy consumption and solar power generation was 9:00 and 13:30
So, for each day, focusing on decrease energy consumption in the morning.
For overall 2016, the highest energy consumption was in August and September; the lowest energy consumption was in July and December. The furnace 2 and 1 had the higher energy consumption before May 2016. Solar generated the strongest power in July; solar generated the weakest power in December and January. Overall house energy consumption was greater than solar power generation in 2016.
So, for each month, focusing on decrease energy consumption in summer and winter. Because overall house energy consumption was much greater than solar power generation, we still need to save energy not depend on solar power.
For rooms, home office had the highest consumption, which was 40.96128 kW; kitchen 38 had lowest energy consumption, which was 0 kW. For devices, Furnace 2 had the highest energy consumption, which was 68.9244 kW; Microwave had the lowest energy consumption, which was 5.53444 kW.
So, furnance had the highest energy consumption. Microwave had the lowest energy consumption. for decrease energy consumption, we can reduce use of furnances.
GitHub Website: https://rmiaous.github.io/house-energy-consumption/